/**
 * @projectName gs_online
 * @package com.answer.wx.common.response
 * @className com.answer.wx.common.response.ResponseListEntity
 */
package com.answer.wx.common.response;

import lombok.Data;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * ResponseListEntity
 * @description 列表数据返回类
 * @author answer_wx
 * @date 2022/8/20 15:31
 * @version 1.0
 */
@Data
public class ResponseListEntity<T> implements Serializable {
    /**
     * 是否有下一页.
     */
    private boolean hasNext = true;
    /**
     * 总条数.
     */
    private long totalCount = 0;
    /**
     * 列表数据.
     */
    private List<T> list;
    /**
     * 额外信息.
     */
    private Object extra;

    private ResponseListEntity() {

    }

    public static <T> ResponseListEntity<T> newInstance() {
        return new ResponseListEntity<>();
    }

    public void setList(List<T> list) {
        if (list == null) {
            return;
        }

        this.list = list;
        if (list.isEmpty()) {
            this.totalCount = 0;
        }
    }
}